package com.ywqf_api.controller;

import com.ywqf_api.dto.exc.ReturnExcution;
import com.ywqf_api.entity.FeeDetail;
import com.ywqf_api.entity.order;
import com.ywqf_api.enums.ReturnEnum;
import com.ywqf_api.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Administrator on 2018/4/2 0002.
 */
@Api(description="order接口",produces="application/json")
@Controller
@RequestMapping("order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    //缴费订单详情
    @ApiOperation(value = "缴费订单详情接口", httpMethod = "POST", notes = "缴费订单详情接口")
    @RequestMapping(value = "orderDetail",method = RequestMethod.POST)
    @ResponseBody
    public ReturnExcution orderDetail(Integer paymentId,Integer orderId,Integer type){
        FeeDetail find = orderService.orderDetail(paymentId,orderId,type);
        if(find == null){
            return new ReturnExcution(ReturnEnum.FIND_FILE,null);
        }
        return new ReturnExcution(ReturnEnum.FIND_SUCCESS,find);
    }

    //家政订单详情
    @ApiOperation(value = "家政订单详情", httpMethod = "POST", notes = "家政订单详情")
    @RequestMapping(value = "houseKeepOrderDetail",method = RequestMethod.POST)
    @ResponseBody
    public ReturnExcution houseKeepOrderDetail(Integer orderId){
        order find = orderService.houseKeepOrderDetail(orderId);
        if(find == null){
            return new ReturnExcution(ReturnEnum.FIND_FILE,null);
        }
        return new ReturnExcution(ReturnEnum.FIND_SUCCESS,find);
    }

    //我的订单
    @ApiOperation(value = "我的订单接口", httpMethod = "POST", notes = "我的订单接口")
    @RequestMapping(value = "findMyOrder",method = RequestMethod.POST)
    @ResponseBody
    public ReturnExcution findMyOrder(Integer customerId,Integer goodsTypeId){
        List<order> find = orderService.findMyOrder(customerId,goodsTypeId);
        if(find == null){
            return new ReturnExcution(ReturnEnum.FIND_SUCCESS,null);
        }
        return new ReturnExcution(ReturnEnum.SUCCESS,find);
    }

    //缴费记录
    @ApiOperation(value = "缴费记录接口", httpMethod = "POST", notes = "缴费记录接口")
    @RequestMapping(value = "paymentRecords",method = RequestMethod.POST)
    @ResponseBody
    public ReturnExcution paymentRecords(Integer houseId,Integer type){
        List find = orderService.paymentRecords(houseId,type);
        if(find == null){
            return new ReturnExcution(ReturnEnum.FEE_NULL,null);
        }
        return new ReturnExcution(ReturnEnum.FIND_SUCCESS,find);
    }


}
